<template>
	<view>
		<cu-custom bgColor="bg-cyan" isBack>
			<block slot="content">video视频播放</block>
		</cu-custom>
		<view class="smart-panel-head">
			<view class="smart-panel-head-title">
				video
			</view>
		</view>
		<view class="smart-padding-wrap">
			<video id="myVideo" :danmu-list="danmuList" enable-danmu="true" danmu-btn="true" controls="true"
				src="https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/%E7%AC%AC1%E8%AE%B2%EF%BC%88uni-app%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D%EF%BC%89-%20DCloud%E5%AE%98%E6%96%B9%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B@20200317.mp4"></video>
		</view>
		<view class="uni-list-cell-db">
			<input v-model="danmuValue" class="uni-input" type="text" placeholder="在此处输入弹幕内容" />
		</view>
		<view class="uni-btn-v">
			<button @click="sendDanmu" class="page-body-button">发送弹幕</button>
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: '',
				danmuList: [{
						text: '第 1s 出现的弹幕',
						color: '#ff0000',
						time: 1
					},
					{
						text: '第 3s 出现的弹幕',
						color: '#ff00ff',
						time: 3
					}
				],
				danmuValue: ''
			}
		},
		onReady: function(res) {
			this.videoContext = uni.createVideoContext('myVideo')
			setTimeout(() => {

			}, 350);
		},
		methods: {
			sendDanmu: function(e) {
				this.videoContext.sendDanmu({
					text: this.danmuValue,
					color: 'red'
				});
				this.danmuValue = '';
			}
		},
	}
</script>

<style>
	video{
		width: 100%;
	}
	.btn-v{
		margin: 15rpx;
	}
</style>
